﻿var Model = {};
var BLL = {};

//数据模型类(伪)
//坐标类
Model.CPoint = jClass({
    _constructor: function (x, y) {
        this.x = x;
        this.y = y;
    },
    x: null,
    y: null
});

//关键点类
Model.CKeyPoint = jClass.extend(Model.CPoint, {
    id: null,
    isselected: false,
    shapeid: null
});

//图形类
Model.CShape = jClass({
    id: null,
    type: "line",
    keypoints: new Array()
});

function draeCanvas(shapemodel) {
    ctx.beginPath();
    ctx.moveTo(shapemodel.keypoints[0].x, shapemodel.keypoints[0].x);
    for (var i = 0; i < shapemodel.keypoints.length; i++) {
        ctx.lineTo(shapemodel.keypoints[i].x, shapemodel.keypoints[i].y);
    }
    ctx.closePath();
    ctx.stroke();
}

function getModelList() {
    var modellist = new Array();
    var _model1 = new Model.CKeyPoint(30, 30);
    var _model2 = new Model.CKeyPoint(80, 30);
    var _model3 = new Model.CKeyPoint(80, 90);
    var _model4 = new Model.CKeyPoint(30, 90);
    modellist.push(_model1);
    modellist.push(_model2);
    modellist.push(_model3);
    modellist.push(_model4);
    return modellist;
}


function test() {
    var myshape = new Model.CShape();
    myshape.keypoints = getModelList();
    draeCanvas(myshape);
}